package com.opencloud.msg.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.opencloud.common.model.PageParams;
import com.opencloud.common.mybatis.base.service.impl.BaseServiceImpl;
import com.opencloud.msg.client.model.entity.HttpNotifyLogs;
import com.opencloud.msg.mapper.HttpNotifyLogsMapper;
import com.opencloud.msg.service.HttpNotifyLogsService;
import org.springframework.stereotype.Service;

/**
 * 异步通知日志接口
 *
 * @author: liuyadu
 * @date: 2019/2/13 14:39
 * @description:
 */
@Service
public class HttpNotifyLogsServiceImpl extends BaseServiceImpl<HttpNotifyLogsMapper, HttpNotifyLogs> implements HttpNotifyLogsService {

    /**
     * 分页查询
     *
     * @param pageParams
     * @return
     */
    @Override
    public IPage<HttpNotifyLogs> findPage(PageParams pageParams) {
        HttpNotifyLogs query = pageParams.mapToObject(HttpNotifyLogs.class);
        QueryWrapper<HttpNotifyLogs> queryWrapper = new QueryWrapper();
        queryWrapper.lambda()
                .likeRight(ObjectUtils.isNotEmpty(query.getUrl()), HttpNotifyLogs::getUrl, query.getUrl())
                .eq(ObjectUtils.isNotEmpty(query.getType()), HttpNotifyLogs::getType, query.getType())
                .eq(ObjectUtils.isNotEmpty(query.getResult()), HttpNotifyLogs::getResult, query.getResult());
        return baseMapper.selectPage(pageParams, queryWrapper);
    }
}
